<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="com.tjsinfo.tjsoa.vote.vo.TVoteHead,com.tjsinfo.tjsoa.vote.vo.TVoteConformation,java.awt.*, java.text.*, java.util.*" %>
<%@ page import="org.jfree.chart.*" %>
<%@ page import="org.jfree.chart.axis.*" %>
<%@ page import="org.jfree.chart.labels.StandardCategoryItemLabelGenerator" %>
<%@ page import="org.jfree.chart.plot.*" %>
<%@ page import="org.jfree.chart.renderer.*" %>
<%@ page import="org.jfree.chart.servlet.ServletUtilities" %>
<%@ page import="org.jfree.ui.TextAnchor" %>
<%@ page import="org.jfree.data.category.DefaultCategoryDataset" %>
<%@ page import="org.jfree.chart.renderer.category.BarRenderer3D" %>
<%
	double[] countList=(double[])request.getAttribute("countList");
	Comparable[] comparable=(Comparable[])request.getAttribute("comparable");
	TVoteHead head=(TVoteHead)request.getAttribute("head");
	TVoteConformation conformation=(TVoteConformation)request.getAttribute("conformation");
	String leftOut=(String)request.getAttribute("leftOut");
  //The data for the bar chart
  double[] data = countList;
  //The labels for the bar chart
  Comparable[] labels2 = comparable;
  DefaultCategoryDataset dataset = new DefaultCategoryDataset();
  for (int i = 0; i < data.length; i++) {
    dataset.addValue(data[i], "zx", labels2[i]);
  }
  
  JFreeChart chart = ChartFactory.createBarChart3D(head.getName()+"汇总情况",conformation.getName(), leftOut, dataset,PlotOrientation.HORIZONTAL, false, false, false);
  chart.setBackgroundPaint(new Color(0xE1E1E1));
  Plot pieplot = (Plot)chart.getPlot();
  pieplot.setNoDataMessage("无数据");
  CategoryPlot plot = chart.getCategoryPlot();
  
  // 设置Y轴显示整数

  NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
  rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
  
  CategoryAxis domainAxis = plot.getDomainAxis();
  //设置距离图片左端距离
  domainAxis.setLowerMargin(0.05);
  
  BarRenderer3D renderer = new BarRenderer3D();
  //设置柱的颜色
  renderer.setSeriesPaint(0, new Color(36,123,206));
  plot.setRenderer(renderer);
  int width=800;
  int height=400;
  if(countList.length>8)height=height+30*(countList.length-7);
  String filename = ServletUtilities.saveChartAsPNG(chart, width, height, null, session);
  String graphURL = request.getContextPath() + "/servlet/DisplayChart?filename=" + filename;
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>粮油集团办公自动化协作平台</title>
	</head>
	<body>
		<img src="<%= graphURL %>" border=0/>
	</body>
</html>
